package cn.itsource.campus.service.impl;

import cn.itsource.campus.domain.Teacher;
import cn.itsource.campus.mapper.TeacherMapper;
import cn.itsource.campus.service.ITeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TeacherServiceImpl implements ITeacherService {

    @Autowired
    private TeacherMapper teacherMapper;
    @Override
    public void save(Teacher teacher) {
        //如果id为空就新增，否则就是修改
        if (teacher.getId() == null) {
            teacherMapper.save(teacher);
        }else{
            teacherMapper.update(teacher);
        }
    }

    @Override
    public void delete(Long id) {
        teacherMapper.delete(id);
    }

    @Override
    public Teacher get(Long id) {
        return teacherMapper.get(id);
    }

    @Override
    public List<Teacher> getAll() {
        return teacherMapper.getAll();
    }

    @Override
    public void batchSave(List<Teacher> teachers) {
        teacherMapper.batchSave(teachers);
    }
}
